﻿@model ListFormDataModel

@{
    ViewBag.Title = "FormData";
    ViewBag.HideSideBar = true;
    ViewBag.IdleEven = 0;
}

<div class="folder">
    <div class="folder-heading">
        <h2 class="left">@Model.FormName > @Loc("Form data")</h2>

        <div class="grid-paging right">
            @Html.DisplayFor(m => m.PagingInfo)
        </div>
        <div class="clear"></div>
    </div>

    @if (Model.Items.Count() > 0) { 
        <table class="grid">
            <tr>
                <th class="w30">@Loc("ID")</th>
                <th class="w110">@Loc("Created")</th>
                @foreach (var column in Model.Columns)
                {
                    <th>@column.Name</th>
                }
                <th class="w50"></th>
            </tr>
            @foreach (var item in Model.Items)
            {
                <tr class="@(ViewBag.IdleEven % 2 == 0 ? "even" : "idle")">
                    <td>@item.ID</td>
                    <td>@item.Created</td>
                    @foreach (var column in Model.Columns)
                    {
                        var value = item.Columns.First(c => c.FieldDefinitionID == column.ID);
                        <td>
                        @if (value != null)
                        { 
                            if (value.FieldDefinition.FieldType == Neptuo.Forms.Core.FieldType.FileField)
                            {
                                @Html.ActionLink(value.GetDisplayValue(), "File", "Form", new { FieldID = value.ID }, null)
                            }
                            else
                            {
                                @value.GetDisplayValue()
                            }
                        }
                        </td>
                    }
                    <td></td>
                </tr>
                ViewBag.IdleEven++;
            }
        </table>
    }

    <div class="folder-foot">
        @Html.ActionLink((L)"Back to forms", "forms", "project", new { ProjectID = Model.ProjectID }, null)
    </div>
</div>

